home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlb20 / lib / _fltsi.cpp < prev    next >
Text File  |  1992-04-26  |  2KB  |  104 lines

  1. #ifdef __M68881__
  2. |
  3. | long integer to double float conversion routine
  4. |
  5. | Written by M.Ritzert
  6. | 22.11.91
  7. | ritzert@dfg.dbp.de
  8. |
  9.     .text
  10.     .even
  11.     .globl    __floatsidf, ___floatsidf
  12.  
  13. __floatsidf:
  14. ___floatsidf:
  15.     fintrzd a7@(4),fp0        | load long int to fp0
  16.     fmoved    fp0,a7@-        | get double from fp0
  17.     moveml    a7@+,d0-d1
  18.      rts
  19.  
  20. #endif    __M68881__
  21. #ifdef    sfp004
  22.  
  23. | long integer to double float conversion routine
  24. |
  25. | Written by M.Ritzert
  26. | 5.10.90
  27. | ritzert@dfg.dbp.de
  28. |
  29.  
  30. | addresses of the 68881 data port. This choice is fastest when much data is
  31. | transferred between the two processors.
  32.  
  33. comm =     -6    |    fpu command reg
  34. resp =    -16    |    fpu response reg
  35. zahl =      0    |    fpu data reg
  36.  
  37. | waiting loop ...
  38. |
  39. | wait:
  40. | ww:    cmpiw    #0x8900,a1@(resp)
  41. |     beq    ww
  42. | is coded directly by
  43. |    .long    0x0c688900, 0xfff067f8
  44.  
  45.     .text
  46.     .even
  47.     .globl    __floatsidf, ___floatsidf
  48.  
  49. __floatsidf:
  50. ___floatsidf:
  51.     lea    0xfffa50,a0
  52.     movew    #0x4000,a0@(comm)    | load long int to fp0
  53.     cmpiw    #0x8900,a0@(resp)    | check
  54.     movel    a7@(4),a0@
  55.     movew    #0x7400,a0@(comm)    | get double from fp0
  56.     .long    0x0c688900, 0xfff067f8
  57.     movel    a0@,d0
  58.     movel    a0@,d1
  59.     rts
  60.  
  61. #endif    sfp004
  62. #if !defined    (__M68881__) && !defined (sfp004)
  63.  
  64. | long integer to double float conversion routine
  65. |
  66. | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  67. | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  68. |
  69. |
  70. | Revision 1.2, kub 01-90 :
  71. | added support for denormalized numbers
  72. |
  73. | Revision 1.1, kub 12-89 :
  74. | Ported over to 68k assembler
  75. |
  76. | Revision 1.0:
  77. | original 8088 code from P.S.Housel
  78.  
  79. BIAS8    =    0x3FF-1
  80.  
  81.     .text
  82.     .even
  83.     .globl    __floatsidf, ___floatsidf
  84.  
  85. __floatsidf:
  86. ___floatsidf:
  87.     movel    sp@(4),d0    | get the 4-byte integer
  88.     moveml    d2-d7,sp@-    | save registers to make norm_df happy
  89.  
  90.     movel    d0,d4        | prepare result mantissa
  91.     clrl    d5
  92.     movew    #BIAS8+32-11,d0    | radix point after 32 bits
  93. 0:
  94.     movel    d4,d2        | set sign flag
  95.     swap    d2
  96.     tstw    d2        | check sign of number
  97.     bge    1f        | nonnegative
  98.     negl    d4        | take absolute value
  99. 1:
  100.     clrw    d1        | set rounding = 0
  101.     jmp    norm_df
  102.  
  103. #endif    /* !__M68881__ && !sfp004    */
  104.